package com.xdwanj.action;

import com.xdwanj.config.SpringConfiguration;
import com.xdwanj.service.CmdService;
import com.xdwanj.util.CmdConst;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Scanner;

public class Main {

    public static CmdService cmdService;

    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfiguration.class);
        cmdService = context.getBean(CmdService.class);

        String command = null;
        Scanner input = new Scanner(System.in);

        while (true) {
            System.out.print("输入指令: ");
            command = input.next();
            switch (command) {
                case CmdConst.STUDY:
                    while (true) {
                        cmdService.study();
                    }
                case CmdConst.ADD:
                    while (true) {
                        cmdService.add();
                    }
                case CmdConst.ALL:
                    cmdService.all();
                default:
                    System.out.println("again~");
            }
        }

    }
}
